package cn.webrx.coll;/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * <p>Project: jse2204 - cn.webrx.coll.HashSet1
 * <p>Powered by webrx On 2022-09-19 16:20:46
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class HashSet1 {
    public static void main(String[] args) {
        //Set接口集合 HashSet 不允许有重复 无序集合
        Set<Integer> set = new HashSet<>();
        //添加
        set.add(10);
        set.add(10);
        set.addAll(List.of(11, 22, 33, 11, 22, 44, 55));
        System.out.println(set.size());
        System.out.println(set);

        //删除
        //set.clear(); 清空
        System.out.println(set.remove(1));
        System.out.println(set.removeAll(List.of(11, 22, 33, 66)));
        System.out.println(set);

        //判断
        System.out.println(set.contains(55));
        System.out.println(set.containsAll(List.of(44,55,11)));
        System.out.println(set.isEmpty());

        //遍历
        for(Integer i : set){
            System.out.println(i);
        }


    }
}
